<?php
include('rootlogin.php');
//include('../incsession.php');
session_start();
$level_def=array("","EASY", "INTERMEDIATE", "DIFFICULT");
$aid = 50;

if(isset($_POST['submit']))
{
	


	$para_num = $_POST['np'];
	$seq = 1;
	for($i=1;$i<=$para_num;$i++)
	{
		$seten_num = $_POST['np'.$i];
		for($j=1;$j<=$seten_num;$j++)
		{
			$text = $_POST['p'.$i.'s'.$j.'_t'];
			$type = $_POST['p'.$i.'s'.$j];
			
			$sql = "INSERT INTO paragraph SET aid='".$aid."', seq='".$seq."', type='".$type."', text='".$text."', paragraph='".$i."'";
			mysql_query($sql, $orcp_con);
			
			$seq ++;
		}
	}
	header ("location: multiple_choice.php");
}
?>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="framestyle.css" type="text/css" media="screen">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script>
function addSentence(pid)
{
	obj = "#p"+pid;
	num = parseInt($('#np'+pid).val()) + 1;
	//alert("p"+pid+"s"+num);
	$(obj).append("<input type='text' size='80' name='p"+pid+"s"+num+"_t'><font size='3'><input type='radio' name='p"+pid+"s"+num+"' value='0' checked>None<input type='radio' name='p"+pid+"s"+num+"' value='1'>Main sentence<input type='radio' name='p"+pid+"s"+num+"' value='2'>Example sentence</font><br>");
	$('#np'+pid).val(num);
}

function addParagraph()
{
	obj = "#paragraphs";
	num = parseInt($('#np').val()) + 1;
	$(obj).append("Paragraph"+num+":<input type='hidden' id='np"+num+"' value='1' name='np"+num+"'><table border='1'><tr><td id='p"+num+"'><input type='text' size='80' name='p"+num+"s1_t'><font size='3'><input type='radio' name='p"+num+"s1' value='0' checked>None<input type='radio' name='p"+num+"s1' value='1'>Main sentence<input type='radio' name='p"+num+"s1' value='2'>Example sentence</font><br></td><td valign='top'><input type='button' value='Add a sentence' onClick='addSentence("+num+")'></td></tr></table>");
	$('#np').val(num);
}
</script>
</head>


<body>
<div id="wrapper">
<div id="title">Online Listening Program</div>

<div id="main">
<hr/>
<div id="title2">ARTICLE</div>
<hr/><br>
<form action='article.php' method='post'>
<input type='hidden' id='np' value='1' name='np'>
<div id='paragraphs'>
Paragraph1:	
<input type='hidden' id='np1' value='1' name='np1'>
<table border='1'>
<tr><td id='p1'>
		<input type='text' size='80' name='p1s1_t'><font size='3'><input type='radio' name='p1s1' value='0' checked>None<input type='radio' name='p1s1' value='1'>Main sentence<input type='radio' name='p1s1' value='2'>Example sentence</font><br>
	</td><td valign='top'><input type='button' value='Add a sentence' onClick='addSentence(1)'></td></tr>
</table>
</div>
<br>
<input type='button' value='Add a paragraph' onClick='addParagraph()'>
<br>
<table width='100%'>
<tr><td align='right'><input type='submit' value='Next' name='submit'></td></tr>
</table>
</form>

</div>
</div>
</body>

